/* Copyright (C) 2011 clueless <clueless.mmopeon@gmail.com>
 *
 * This file is part of MMO Peon.
 *
 * MMO Peon is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * MMO Peon is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MMO Peon.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "coords.h"
#include <cmath>

float RadToDeg2(float rad)
{
    return rad * 180.0 / pi;
}

float RomCoords::Distance(const RomCoords &target) const
{
    float a = fabs(x - target.x);
    float b = fabs(y - target.y);
    float c = fabs(z - target.z);
    return sqrt((a*a) + (b*b) + (c*c));
}

float RomCoords::Angle(const RomCoords &target) const
{
    float yLen = target.y - y;
    float xLen = target.x - x;
    return RadToDeg2(atan2(xLen, yLen));
}

float RomVectors::Angle()
{
    return RadToDeg2(atan2(x, y));
}
